import React, { Component } from 'react';
import {
    View,
    Button,
    StyleSheet
} from 'react-native';
import BaseComponentF from './BaseComponentF';
import HttpUil from '../util/HttpUtil';

class RequestDemo extends Component {
    render() {
        return (
            <View style={Style.container}>
                <Button title='get' onPress={() => this.doGet()} />
                <Button title='post' onPress={() => this.doPost()} />
            </View>
        );
    }

    doGet() {
        HttpUil.doRequest('GET', "https://www.sojson.com/open/api/weather/json.shtml", { city: "北京" })
            .then(response => {
                console.log(`response:${JSON.stringify(response)}`);
            }).catch(error => {
                console.log(`error:${error}`);
            });
    }

    doPost() {
        HttpUil.doRequest('POST', 'http://www.baidu.com');
    }

    
}


const Style = StyleSheet.create({
    container: {

    }
});
export default BaseComponentF(RequestDemo); 